<template>
  <PageWrapper contentFullHeight dense>
    <BasicTable @register="registerTable">
      <!-- <template #toolbar>
        <a-button type="primary" @click="handleAdd">下载</a-button>
      </template> -->
    </BasicTable>
  </PageWrapper>
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { useRouter } from 'vue-router';
  import { useI18n } from '/@/hooks/web/useI18n';
  // import { useMessage } from '/@/hooks/web/useMessage';
  import { BasicTable, useTable } from '/@/components/Table';
  import { PageWrapper } from '/@/components/Page';
  import { useDrawer } from '/@/components/Drawer';
  import { handleFetchParams } from '/@/utils/lamp/common';
  import { ActionEnum } from '/@/enums/commonEnum';
  import { RoleEnum } from '/@/enums/roleEnum';
  import { RouteEnum } from '/@/enums/biz/tenant';
  import { columns, searchFormSchema } from './defDict.data';
  import { getFinalResultByYearJX, getTaskTemporaryWorkList } from '/@/api/basic/qimo/index';
  // import { getFinalResultByYearJXVO } from '/@/api/basic/qimo/model/index';
  export default defineComponent({
    // 若需要开启页面缓存，请将此参数跟菜单名保持一致
    name: '数据字典',
    components: { BasicTable, PageWrapper },
    setup() {
      const { t } = useI18n();
      // const { createMessage, createConfirm } = useMessage();
      // 编辑页弹窗
      const [registerDrawer, { openDrawer }] = useDrawer();
      const { replace } = useRouter();

      // 表格
      const [registerTable, { reload }] = useTable({
        title: '教学单位年度目标考核结果列表',
        // api: getTaskTemporaryWorkList,
        api: getFinalResultByYearJX,

        columns: columns(),
        formConfig: {
          labelWidth: 120,
          schemas: searchFormSchema(),
        },
        beforeFetch: handleFetchParams,
        useSearchForm: true,
        showTableSetting: true,
        bordered: true,
        rowKey: 'id',
        rowSelection: {
          type: 'checkbox',
        },
        // actionColumn: {
        //   width: 220,
        //   title: t('common.column.action'),
        //   dataIndex: 'action',
        // },
      });
      // const fileList = ref<getFinalResultByYearJXVO[] | any[]>([]);
      // console.log(fileList, 6666);
      // 弹出复制页面
      function handleCopy(record: Recordable, e: Event) {
        e?.stopPropagation();
        openDrawer(true, {
          record,
          type: ActionEnum.COPY,
        });
      }

      // 弹出新增页面
      function handleAdd() {
        openDrawer(true, {
          type: ActionEnum.ADD,
        });
      }

      // 弹出编辑页面
      function handleEdit(record: Recordable, e: Event) {
        e?.stopPropagation();
        openDrawer(true, {
          record,
          type: ActionEnum.EDIT,
        });
      }

      // 新增或编辑成功回调
      function handleSuccess() {
        reload();
      }

      // async function batchDelete(ids: any[]) {
      //   await taskNegativeItemDEL(ids);
      //   createMessage.success(t('common.tips.deleteSuccess'));
      //   handleSuccess();
      // }

      // 点击单行删除
      // function handleDelete(record: Recordable, e: Event) {
      //   e?.stopPropagation();
      //   if (record?.id) {
      //     batchDelete([record.id]);
      //   }
      // }

      // 点击批量删除
      // function handleBatchDelete() {
      //   const ids = getSelectRowKeys();
      //   if (!ids || ids.length <= 0) {
      //     createMessage.warning(t('common.tips.pleaseSelectTheData'));
      //     return;
      //   }
      //   createConfirm({
      //     iconType: 'warning',
      //     content: t('common.tips.confirmDelete'),
      //     onOk: async () => {
      //       await batchDelete(ids);
      //     },
      //   });
      // }

      // 查看字典项
      // function handleViewItem(record: Recordable, e: Event) {
      //   e.stopPropagation();
      //   replace({
      //     name: RouteEnum.DICT_ITEM,
      //     params: { dictId: record.id },
      //     query: { name: record.name, key: record.key, remark: record.remark },
      //   });
      // }

      return {
        t,
        registerTable,
        registerDrawer,
        RoleEnum,
        handleAdd,
        handleCopy,
        handleEdit,
        // handleDelete,
        handleSuccess,
        // handleBatchDelete,
        // handleViewItem,
      };
    },
  });
</script>
